import { EditableExcelTableI18n } from './types';
import { zhCN } from './locales/zh-CN';
import { enUS } from './locales/en-US';

const locales: Record<string, EditableExcelTableI18n> = {
    'zh-CN': zhCN,
    'en-US': enUS,
};

export function getI18n(locale: string = 'zh-CN'): EditableExcelTableI18n {
    return locales[locale] || zhCN;
}

export function formatMessage(message: string, params?: Record<string, string>): string {
    if (!params) return message;

    return message.replace(/\{(\w+)\}/g, (match, key) => {
        return params[key] || match;
    });
}

export * from './types';
export * from './locales/zh-CN';
export * from './locales/en-US';
